<?php

use Faker\Factory as Faker;
use App\Models\ChannelRelayUser;
use App\Repositories\ChannelRelayUserRepository;

trait MakeChannelRelayUserTrait
{
    /**
     * Create fake instance of ChannelRelayUser and save it in database
     *
     * @param array $channelRelayUserFields
     * @return ChannelRelayUser
     */
    public function makeChannelRelayUser($channelRelayUserFields = [])
    {
        /** @var ChannelRelayUserRepository $channelRelayUserRepo */
        $channelRelayUserRepo = App::make(ChannelRelayUserRepository::class);
        $theme = $this->fakeChannelRelayUserData($channelRelayUserFields);
        return $channelRelayUserRepo->create($theme);
    }

    /**
     * Get fake instance of ChannelRelayUser
     *
     * @param array $channelRelayUserFields
     * @return ChannelRelayUser
     */
    public function fakeChannelRelayUser($channelRelayUserFields = [])
    {
        return new ChannelRelayUser($this->fakeChannelRelayUserData($channelRelayUserFields));
    }

    /**
     * Get fake data of ChannelRelayUser
     *
     * @param array $postFields
     * @return array
     */
    public function fakeChannelRelayUserData($channelRelayUserFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'channel_id' => $fake->randomDigitNotNull,
            'wechat_user_id' => $fake->randomDigitNotNull,
            'relay_num' => $fake->randomDigitNotNull,
            'read_num' => $fake->randomDigitNotNull,
            'status' => $fake->randomDigitNotNull,
            'updated_at' => $fake->word,
            'created_at' => $fake->word
        ], $channelRelayUserFields);
    }
}
